<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/css/mycss.css">
    <link rel="stylesheet" href="/Public/em-ui/index.css">
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
</head>
<body>
    <div id="app" class="modal-dialog left-dia">
        <div class="modal-content left-con">
            <div class="modal-header left-hea">
                <div class="modal-title">
                    <h4>登录</h4>
                </div>
            </div>
            <div class="modal-body">
                <div v-if="mes" class="alert alert-danger">{{mes}}
                    <button class="close" @click="mes=''">&times;</button>
                </div>
                <el-form ref="lgoinForm" :model="logindata" :rules="rules" label-width="80px">
                    <el-form-item label="用户名" prop="login">
                        <el-input v-model="logindata.login" />
                    </el-form-item>
                    <el-form-item label="密码" prop="password">
                        <el-input v-model="logindata.password" />
                    </el-form-item>
                </el-form>
                <div class="row">
                    <div class="col-xs-4 col-xs-offset-9">
                        <el-button @click="dologin()">登录</el-button>
                    </div>
                </div>
            </div>
        </div>
    </div>


    <script src="/Public/js/vue.min.js"></script>
    <script src="/Public/js/vue-resource.min.js"></script>
    <script src="/Public/em-ui/index.js"></script>
    <script src="/Public/js/jquery-1.11.1.min.js"></script>
    <script src="/Public/js/bootstrap.min.js"></script>
    <script>
        Vue.http.options.emulateJSON=true;
        new Vue({
            el: "#app",
            data: {
                mes: '',
                logindata: {},
                rules: {
                    login: {required: true, message: '请输入用户名'},
                    password: {required: true, message: '请输入密码'}
                }
            },
            methods:{
                dologin(){
                    this.$refs.lgoinForm.validate(valid => {
                        if (!valid) {
                        return;
                    }
                    this.$http.post('/Admin/Index',this.logindata).then(resp =>{
                        let result = resp.data;
                    console.log(result);
                    if(result.status){
                        if(result.role_id ==1){
                            location ="/Admin/main";
                        } else if(result.role_id ==2){
                            location ="/Admin/Bike";
                        } else if(result.role_id ==3){
                            location ="/Admin/Finance";
                        }
                    }else{
                        this.mes= result.error;
                    }
                })
                });
                }
            }
        })
    </script>

</body>
</html>